<?php
//微网站类
class WebsiteAction extends Action {
	//查询所有微网站模板
	public function getWebsiteTemplateList($templateGroupName = ''){
		$websitetemplate = m('website_template');
		$retVal = Session::init();
		if (!$retVal) {
			Output::instance()->resultCode(code_access_denied);
			return;
		}	
		if(!empty($templateGroupName)){
			$where['templateGroup'] = array('eq',$templateGroupName);
		}
		$templates = $websitetemplate->alias("tpl")->where($where)
			->field("tpl.id, tpl.templateName, tpl.picUrl, tpl.description")->select();
		if ($templates) {
			$count = $websitetemplate->where($where)->count();
			Output::instance()->objArray($templates, $count);	
		} else {
			Output::instance()->resultCode(code_success);
		}
	}
	
	//根据模板ID查询微网站模板
	//$id:数据表website_template中的ID号
	public function getWebsiteTemplateById($id){
		$websitetemplate = m('website_template');
		$retVal = Session::init();
		if (!$retVal) {
			Output::instance()->resultCode(code_access_denied);
			return;
		}
		$condition["id"] = array("eq",$id);
		$arr = $websitetemplate->where($condition)->find();
		if ($arr) {
			Output::instance()->object($arr);
		} else {
			Output::instance()->resultCode(code_success);
		}	
	}		
}